package itheima.com.SocketApi;


import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

//客户端
public class SocketTCP01Clienmt {

    public static void main(String[] args) throws IOException {
//        System.out.println("InetAddress.getLocalHost()===="+InetAddress.getLocalHost());
//        开启socket连接 InetAddress.getLocalHost() 是本机 IP地址
        Socket socket = new Socket(InetAddress.getLocalHost(), 9999);
//        socket
        System.out.println("客户端 socket返回="+socket.getClass());


        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("hello world".getBytes());



        outputStream.close();
        socket.close();
        System.out.println("客户端退出.............");
    }

}
